<p class="pageTitle"><%= l(:common, :editing) %> - <%= link_to @artwork.name, admin_artwork_url(@artwork) %> - <%=Category.l_name.pluralize.capitalize %></p>

<%= error_messages_for :category %>

<% tabnav :artwork do %>
  <p> <%= l(:help, 'new artwork', :req_category)%> </p>

  <p class="sectionH">Listed under:</p>
  <div id="categories">
    <%= render :partial => "admin/categories/list" %>
  </div>

  <br/><p class="sectionH">Add to existing category:</p>
    <% form_tag 'javascript:void(0)' do %>
      <%= select_tag "cat_to_add", "<option>-- Add to Category --</option>" + options_from_collection_for_select(Category.find(:all), :id, :name_with_path) %>      
    <%= observe_field "cat_to_add", :update => 'categories',
        :url => {:controller => 'admin/artworks', :action => 'add_category'},
        :with => "'category=' + encodeURIComponent(value) + '&artwork=' + #{@artwork.id}" %>
    <% end %>
    
  <br/><p class="sectionH">Add to new category:</p>
  The category will then be available for other artworks.  Please specify the name in English, for now.
  
  <% form_for [:admin, @category], :builder => TabledBuilder do |f| %>
    <%= hidden_field_tag :artwork_id, params[:artwork_id]%>
    <table class="center">
      <%= f.text_field :name, :required => true, :label => l(:common, :name) %>
      <tr>
        <td class="tdRight">
          <label for="parent">
            <%= Category.l_attr(:parent) %> <span class="required"><%= l(:common, :required) %></span>:
          </label>
        </td>
        <td>
          <%= select_tag "parent", "<option>-- Parent Category --</option>" + options_from_collection_for_select(Category.find(:all), :id, :name_with_path) %>
        </td>
       </tr>
       <tr>
         <td colspan="2" class="tdCenter">
           <%= f.submit Category.l_attr(:add) %>
         </td>
       </tr>
    </table>
    If you want to add other languages for the category's name to appear in, go to All Categories, then click Edit next to the category.
  <% end %>
<% end %>